package com.qiaofang.applet.service.other.domain;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Objects;

/**
 * @author QF2019
 */
@Data
@NoArgsConstructor
@ApiModel("新房上下架规则")
public class FirsthandRules {

    @ApiModelProperty("图片开关")
    private boolean housePhoto;

    @ApiModelProperty("图片数量")
    private Integer housePhotoNum;

    @ApiModelProperty("户型图开关")
    private boolean houseTypePhoto;

    @ApiModelProperty("合作有效期内开关")
    private boolean contractDate;

    @ApiModelProperty("保护房开关")
    private boolean marketingHouse;

    @Override
    public boolean equals(Object o) {
        if(this == o){
            return true;
        }
        if(o == null || getClass() != o.getClass()){
            return false;
        }
        FirsthandRules that = (FirsthandRules) o;
        return housePhoto == that.housePhoto &&
                houseTypePhoto == that.houseTypePhoto &&
                contractDate == that.contractDate &&
                marketingHouse == that.marketingHouse &&
                Objects.equals(housePhotoNum, that.housePhotoNum);
    }

    @Override
    public int hashCode() {

        return Objects.hash(housePhoto, housePhotoNum, houseTypePhoto, contractDate, marketingHouse);
    }

    /**
     * 判断是否需要通过mongo库数据处理上下架
     * @return
     */
    public boolean isValidParam(){
        return (housePhoto && housePhotoNum != null && housePhotoNum >= 0) || houseTypePhoto;
    }

    @Override
    public String toString() {
        return "FirsthandRules{" +
                "housePhoto=" + housePhoto +
                ", housePhotoNum=" + housePhotoNum +
                ", houseTypePhoto=" + houseTypePhoto +
                ", contractDate=" + contractDate +
                ", marketingHouse=" + marketingHouse +
                '}';
    }
}
